<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>办事指南</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <style type="text/css">
        .icon {
            width: 1em;
            height: 1em;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
        }
    </style>
    <!--标准mui.css-->
    <link rel="stylesheet" href="__TMPL__/public/assets/wuye/css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="__TMPL__/public/assets/wuye/css/app.css"/>
</head>

<body onload="phone();">

<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">添加手机号<input type="hidden" id="url" value="{$url|default=''}"></h1>
</header>


</body>
<script src="__TMPL__/public/assets/wuye/js/mui.min.js"></script>
<script src="__TMPL__/public/assets/wuye/js/iconfont.js"></script>
<script>
    mui.init({
        swipeBack:true //启用右滑关闭功能
    });
    var url = document.getElementById('url').value;
    function phone() {
        mui.prompt('','请输入手机号','请输入手机号',['确定'],function (e) {
            if(e.value != ''){
                var pattern=/(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
                if(pattern.test(e.value)) {

                    mui.ajax("{:url('portal/wuye/getPhone')}",{
                        data:{phone:e.value,url:url},
                        dataType:'json',//服务器返回json格式数据
                        type:'post',//HTTP请求类型
                        timeout:10000,//超时时间设置为10秒；
                        headers:{'Content-Type':'application/json'},
                        success:function(data){
                            if(data == 1){
                                window.location.href = "{:url('portal/wuye/"+url+"')}";
                            }else{
                                mui.alert(data);
                            }
                        },
                        error:function(xhr,type,errorThrown){
                            //异常处理；
                            console.log(type);
                        }
                    });
                }else{
                    mui.alert('手机号码格式错误',phone());
                }
            }else{
                mui.alert('手机号码不能为空',phone());
            }
        });
    }

</script>
</html>